/*
 * Copyright (c) 2015 Messcat. All rights reserved.
 */
package cc.messcat.dao.system;

import cc.messcat.common.dao.BaseDaoImpl;
import cc.messcat.common.util.CollectionUtil;
import cc.messcat.entity.area.Area;
import cc.messcat.entity.system.Role;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Panda
 * @version 1.0
 */
@Repository
public class RoleDaoImpl extends BaseDaoImpl<Role> implements RoleDao {

	@Override
	public Role getRoleByName(String roles) {
		List<Role> list = getCurrentSession().createCriteria(Role.class).add(Restrictions.eq("name", roles)).list();
		return CollectionUtil.isListNotEmpty(list) ? list.get(0) : null;
	}

	@Override
	public List<Role> retrieveRoleAllFilter(String status) {
		List<Role> list = getCurrentSession().createCriteria(Role.class).add(Restrictions.eq("status", status)).list();
		return list;
	}

//	@Override
//	public List<Role> retrieveRoleByArea(Area area) {
//		List<Role> list = getCurrentSession().createCriteria(Role.class).add(Restrictions.eq("areaId", area.getId())).list();
//		return list;
//	}
}